package com.cdpm.system.service.impl;

import com.cdpm.common.core.domain.model.LoginUser;
import com.cdpm.common.utils.SecurityUtils;
import com.cdpm.system.domain.MessageConfig;
import com.cdpm.system.domain.TStrategyConfig;
import com.cdpm.system.domain.vo.BuryingPointContent;
import com.cdpm.system.mapper.BuryingPointContentMapper;
import com.cdpm.system.mapper.MessageConfigMapper;
import com.cdpm.system.service.IBuryingPointContentService;
import com.cdpm.system.service.IMessageConfigService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @description:
 * @author: longjy
 * @create: 2024-08-29 16:52
 **/
@Service
public class MessageConfigServiceImpl implements IMessageConfigService {

    @Resource
    MessageConfigMapper messageConfigMapper;
    @Override
    public List<MessageConfig> findList(MessageConfig messageConfig) {
        List<MessageConfig> list = messageConfigMapper.findList(messageConfig);
        return list;
    }

    @Override
    public int insert(MessageConfig messageConfig) {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        messageConfig.setTemplateId(new Date().getTime());
        messageConfig.setInsertTime(new Date());
        messageConfig.setInsertUser(loginUser.getUser().getUserName()+"");
        messageConfig.setUpdateTime(new Date());
        messageConfig.setUpdateUser(loginUser.getUser().getUserName()+"");
        messageConfig.setIsDelete("0");
        return messageConfigMapper.insert(messageConfig);
    }

    @Override
    public int update(MessageConfig messageConfig) {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        messageConfig.setUpdateTime(new Date());
        messageConfig.setUpdateUser(loginUser.getUser().getUserName()+"");
        return messageConfigMapper.updateById(messageConfig);
    }
    @Override
    public MessageConfig findById(Long templateId) {
        MessageConfig messageConfig = messageConfigMapper.selectById(templateId);
        return messageConfig;
    }

}
